import {createRouter, createWebHistory} from "vue-router";

const Home = () => import("../views/Home/index.vue");
const Login = () => import("../views/Login/index.vue");
const News = () => import("../views/Home/components/News/index.vue");
const Music = () => import("../views/Home/components/Music/index.vue");
const MusicItem = () => import("../views/Home/components/Music/MusicItem.vue");
const NewsItem = () => import("../views/Home/components/News/NewsItem.vue");
const router = createRouter({
    history: createWebHistory(),
    routes: [
        {
            path: "/home",
            component: Home,
            name: "home",
            children: [
                {
                    path: "Music",
                    component: Music,
                    name: "Music",
                    children: [
                        {
                            path: "musicItem/:name/:order?",
                            name: "musicItem",
                            component: MusicItem,
                        },
                    ],
                },
                {
                    path: "news",
                    component: News,
                    name: "news",
                    children: [
                        {
                            path: "newsItem",
                            name: "newsItem",
                            component: NewsItem,
                        },
                    ],
                },
            ],
        },
        {
            path: "/login",
            component: Login,
            name: "login",
        },
        {
            path: "/",
            redirect: '/home'
        },
    ],
    scrollBehavior() {
        // 始终滚动到顶部
        return {top: 0, left: 0};
    },
});

export default router;
